package Pojo;


public class Student {
	public String[] names = new String[30];
	public int dex;

	/**
	 * 添加
	 * 
	 * @param newname
	 */
	public void addName(String newname) {
		for (int i = 0; i < names.length; i++) {
			if (names[i] == null) {
				names[i] = newname;
				break;
			} else {
				if (i == 29) {
					System.out.println("满了！");
				}
			}
		}
	}

	/**
	 * 显示
	 */
	public void showName() {
		for (int i = 0; i < names.length; i++) {
			if (names[i] != null) {
				System.out.println(names[i]);
			} else {
				break;
			}
		}
	}

	/**
	 * 查找
	 * 
	 * @param name
	 * @return
	 */
	public int FindName(String oidname) {
		for (int i = 0; i < names.length; i++) {
			if (names[i] != null) {
				names[i] = oidname;
				dex = i;
				return i;
			}
		}
		return -1;
	}

	/**
	 * 替换
	 * 
	 * @param newname
	 */
	public boolean getName(String oidname, String newname) {
		if (FindName(oidname) != -1) {
			names[dex] = newname;
			return true;
		} else {
			return false;
		}
	}

}
